package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SnowFlakeUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.vo.CiInquiryVo;
import com.ruoyi.system.mapper.extend.CiInquiryExtendMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.CiInquiryMapper;
import com.ruoyi.system.domain.CiInquiry;
import com.ruoyi.system.service.ICiInquiryService;

/**
 * 询价单Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-10-18
 */
@Service
@Transactional
public class CiInquiryServiceImpl implements ICiInquiryService 
{
    @Autowired
    private CiInquiryMapper ciInquiryMapper;
    @Autowired
    private CiInquiryExtendMapper ciInquiryExtendMapper;
    /**
     * 查询询价单
     * 
     * @param id 询价单主键
     * @return 询价单
     */
    @Override
    public CiInquiry selectCiInquiryById(Long id)
    {
        return ciInquiryMapper.selectCiInquiryById(id);
    }

    /**
     * 查询询价单列表
     * 
     * @param ciInquiry 询价单
     * @return 询价单
     */
    @Override
    public List<CiInquiry> selectCiInquiryList(CiInquiry ciInquiry)
    {
        return ciInquiryMapper.selectCiInquiryList(ciInquiry);
    }
    @Override
    public List<CiInquiryVo> selectCiInquiryVoList(CiInquiry ciInquiry)
    {
        return ciInquiryExtendMapper.selectCiInquiryList(ciInquiry);
    }
    /**
     * 新增询价单
     * 
     * @param ciInquiry 询价单
     * @return 结果
     */
    @Override
    public int insertCiInquiry(CiInquiry ciInquiry)
    {
        if(ciInquiry.getId()==null){
        ciInquiry.setId(SnowFlakeUtils.snowFlakeId());
    }
        ciInquiry.setCreateTime(DateUtils.getNowDate());
        return ciInquiryMapper.insertCiInquiry(ciInquiry);
    }

    /**
     * 修改询价单
     * 
     * @param ciInquiry 询价单
     * @return 结果
     */
    @Override
    public int updateCiInquiry(CiInquiry ciInquiry)
    {
        return ciInquiryMapper.updateCiInquiry(ciInquiry);
    }

    /**
     * 批量删除询价单
     * 
     * @param ids 需要删除的询价单主键
     * @return 结果
     */
    @Override
    public int deleteCiInquiryByIds(Long[] ids)
    {
        return ciInquiryMapper.deleteCiInquiryByIds(ids);
    }

    /**
     * 删除询价单信息
     * 
     * @param id 询价单主键
     * @return 结果
     */
    @Override
    public int deleteCiInquiryById(Long id)
    {
        return ciInquiryMapper.deleteCiInquiryById(id);
    }

    /**
     * 批量---逻辑删除
     *
     * @param ids 需要删除的询价单ID
     * @return 结果
     */
    @Override
    public int setDeleteByIds(Long[] ids)
    {
        Long userId = SecurityUtils.getUserId();
        String userNickName = SecurityUtils.getUserNickName();
        return ciInquiryMapper.setDeleteByIds(ids,userId,userNickName);
    }

    /**
     * 删除---逻辑删除
     *
     * @param id 询价单ID
     * @return 结果
     */
    @Override
    public int setDeleteById(Long id)
    {
        Long userId = SecurityUtils.getUserId();
        String userNickName = SecurityUtils.getUserNickName();
        return ciInquiryMapper.setDeleteById(id,userId,userNickName);
    }

}
